import { getUserInfo } from "../tools/cookieMgr";
import request from "../tools/request"
const getProductCategory=()=>{
	return [{value:'sys_car_supplies',text:"汽车用品"},{value:'car_services',text:"汽车服务"},{value:'sys_vip_packages',text:"会员套餐"}]
}

const getProductBrand=()=>{
	return request.get("/Dictionarys/GetDictionaryTreeByDictionaryTypeKey",{key:"car_supplies_brands"});
}

const getCarSuppliesCategory=()=>{
	return request.get("/Dictionarys/GetDictionaryTreeByDictionaryTypeKey",{key:"car_supplies_categorys"});
}

const getCarServicesType=()=>{
    return request.get("/Dictionarys/GetDictionaryTreeByDictionaryTypeKey",{key:"car_services_categorys"});
}

const addCarSupplies=async(data)=>{
    var files=data.files;
    delete data.files;
    const res=await request.post("/SysCarSupplies/Add2",data);
    if(res.code>=0){
        await request.uploadFiles("/Upload/UploadProductImage",{files:files,id:res.data});
    }
    return res
}

const addCarServices=async(data)=>{
    var files=data.files;
    delete data.files;
    const res=await request.post("/SysCarServices/Add2",data);
    if(res.code>=0){
        await request.uploadFiles("/Upload/UploadProductImage",{files:files,id:res.data});
    }
	return res
}

const addVipPackages=(data)=>{
	return request.post("/SysVipPackages/Add",data);
}

const getVipPackageVip=()=>{
    return request.get("/Vips/GetSelect",{carShopId:getUserInfo().carShopId});
}

const getProducts=(data)=>{
    return request.get("/SysProduct/Pagination",{carShopId:getUserInfo().carShopId,...data});
}

export{
	getProductCategory,getProductBrand,getCarSuppliesCategory,getVipPackageVip,getProducts,addCarSupplies,getCarServicesType,addCarServices,addVipPackages
}